package day0306

var (
	res [][]int
	tmp []int
)

func findSubsequences(nums []int) [][]int {
	res = make([][]int, 0)
	backtrack(0, nums, -101)
	return res
}

func backtrack(start int, nums []int, last int) {
	if start > len(nums) {
		return
	}
	if len(tmp) >= 2 {
		comb := make([]int, len(tmp))
		copy(comb, tmp)
		res = append(res, comb)
	}
	hmp := make(map[int]bool)
	for i := start; i < len(nums); i++ {
		if !hmp[nums[i]] && nums[i] >= last {
			hmp[nums[i]] = true
			tmp = append(tmp, nums[i])
			backtrack(i+1, nums, nums[i])
			tmp = tmp[:len(tmp)-1]
		}
	}
}
